package com.amt.configure;

import com.amt.filter.AuthFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 江伟
 * @Title: WebConfig.java
 * @Package com.amt.configure
 * @Description: TODO(权限拦截配置类)
 * @date 2021年3月月27日 下午3:10:14
 * Copyright (c) ©1994-2021 Scjydz.com All Rights Reserved.
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * 配置拦截请求
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authFilter()).addPathPatterns("/gpzfb/**");
    }

    /**
     * @return
     * @description: 注入权限过滤器
     */
    @Bean
    public AuthFilter authFilter() {
        return new AuthFilter();
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/gpzfb/file/card/**").addResourceLocations("file:/usr/local/inquiry/file/card/");
        registry.addResourceHandler("/gpzfb/file/extractionCode/**").addResourceLocations("file:/usr/local/inquiry/file/extractionCode/");
        registry.addResourceHandler("gpzfb/file/doctors/**").addResourceLocations("file:/usr/local/inquiry/file/doctors/");
    }
}
